/* **********************************************************************
*                                                                       *
* Copyright (c) 2004 NMS Communications Corp.  All rights reserved.   *
*                                                                       *
* ********************************************************************* */

/*
 * This file contains the initialization parameters for mspp endpoints
 * and mspp channels.
 *
 * These paramters are used in the api mspCreateEndpoint() and
 * mspCreateChannel().
 *
 *
*/
#ifndef MSPINIT_DEFINED
#define MSPINIT_DEFINED

#include "ctadef.h"

#ifdef __cplusplus
extern "C"
{
#endif


#define MSP_ENDPOINT_PARAM_MAXSIZE      256

typedef enum tag_MSP_MEDIA
{

    MSP_VOICE,
    MSP_FAX

} MSP_MEDIA;

typedef enum tag_MSP_MUX_MEDIA 
{
    MSP_MUX_VOICE,
    MSP_MUX_FAX,
	MSP_MUX_VIDEO,
    MSP_MUX_AUDIO

} MSP_MUX_MEDIA;



// MSPP ENDPOINT INITIALIZATION PARAMETERS

// DS0 Endpoint initialization - address and parameters

typedef struct tag_DS0_ENDPOINT_ADDR
{

    // Address attributes
    DWORD           nTimeslot;        // Timeslot address

} DS0_ENDPOINT_ADDR;

typedef struct tag_DS0_ENDPOINT_PARMS
{

    DWORD size;
    MSP_MEDIA media;

} DS0_ENDPOINT_PARMS;


// RTP Endpoint initialization - address and parameters

typedef struct TAG_RTCP_SESSION_PARMS
{

    // DWORD       size;
    DWORD       forwardPkts;    //  If set to true (1), all RTCP pkts will
                                //    be forwarded to the app.
    char        cname[32];      //  NULL terminated string containing the
                                //    Canonical name identifier
    char        name[32];       //  NULL terminated string containing the user name
    char        email[32];      //  NULL terminatd string containing the email address
    char        phone[32];      //  NULL terminated string containing the phone number
    char        location[32];   //  NULL terminated string containing
                                //    the geographic user location
    char        tool[32];       //  NULL terminated string containing the application
                                //    or tool name
    char        note[32];       //  NULL terminated string containing notice/status

} RTCP_SESSION_PARMS;

typedef struct tag_RTPRTCP_ENDPOINT_ADDR
{

    // RTP parameters
    char       DestIpAddress[20];   // destination IP address in dot notation
    WORD       nDestPort;           // destination port number
    char       SrcIpAddress[20];    // source IP address in dot notation
    WORD       nSrcPort;            // source port number

} RTPRTCP_ENDPOINT_ADDR;

// Disasm Vocoder Payload ID map
typedef struct tag_RTP_PAYLOAD_MAP {
    DWORD   vocoder;
    DWORD   payload_id;
} RTP_PAYLOAD_MAP;

typedef struct tag_RTPRTCP_V6_ENDPOINT_ADDR
{

    // RTPv6 parameters
    char       DestIpv6Address[46];   // destination IPv6 address in ASCII notation
    WORD       nDestPort;             // destination port number
    WORD       ifc_idx;               // network interface index 0-2 (0 - "auto")
    char       SrcIpv6Address[46];    // source IPv6 address in ASCII notation
    WORD       nSrcPort;              // source port number

} RTPRTCP_V6_ENDPOINT_ADDR;

typedef struct tag_RTPRTCP_ENDPOINT_PARMS
{

    DWORD size;
    // QoS parameters
    BYTE TypeOfService;            // Default = 0, type of service in IP header
    DWORD startRtcp;               // Set this to non-zero to start RTCP
                                   //  session. RTCP_SESSION_PARMS structure must be
                                   //  filled in for the RTCP session
    /* RTCP parameters */
    RTCP_SESSION_PARMS rtcpParms;

    DWORD RtpTsFreq;               // Default=8000, timestamp frequency
    DWORD Session_bw;              // Default=64000, session bandwidth

    DWORD   dtmf_event_control;    // Control DTMF RTP Event generation
    DWORD   frameQuota;            // RTP Assembly frame quota
    DWORD   linkEvents;            // Controls link events

    RTP_PAYLOAD_MAP  PayloadMap;

} RTPRTCP_ENDPOINT_PARMS;

typedef struct tag_RTPRTCP_V6_ENDPOINT_PARMS
{

    DWORD size;

    BYTE  trafficClass;  // Indicates the class or priority of the IPv6 packet
    DWORD flowLabel;     // Indicates the specific sequence the IPv6 packet belongs to

    DWORD startRtcp;               // Set this to non-zero to start RTCP
                                   //  session. RTCP_SESSION_PARMS structure must be
                                   //  filled in for the RTCP session
    /* RTCP parameters */
    RTCP_SESSION_PARMS rtcpParms;

    DWORD RtpTsFreq;               // Default=8000, timestamp frequency
    DWORD Session_bw;              // Default=64000, session bandwidth

    DWORD   dtmf_event_control;    // Control DTMF RTP Event generation
    DWORD   frameQuota;            // RTP Assembly frame quota
    DWORD   linkEvents;            // Controls link events

    RTP_PAYLOAD_MAP  PayloadMap;

} RTPRTCP_V6_ENDPOINT_PARMS;

// UDP Endpoint initialization - address and parameters

typedef struct tag_UDP_ENDPOINT_ADDR
{
    // UDP parameters
    char       DestIpAddress[20];  // destination IP address in dot notation
    WORD       nDestPort;          // destination port number
    char       SourceIpAddress[20];// source IP address in dot notation
    WORD       nSourcePort;        // source port number

} UDP_ENDPOINT_ADDR;

typedef struct tag_UDP_V6_ENDPOINT_ADDR
{
    // UDPv6 parameters
    char       DestIpv6Address[46];   // destination IPv6 address in ASCII notation
    WORD       nDestPort;             // destination port number
    WORD       ifc_idx;               // network interface index 0-2 (0 - "auto")
    char       SourceIpv6Address[46];    // source IPv6 address in ASCII notation
    WORD       nSourcePort;              // source port number

} UDP_V6_ENDPOINT_ADDR;


typedef struct tag_UDP_ENDPOINT_PARMS
{

    DWORD size;
    // QoS
    BYTE TypeOfService;            // IPv4 TOS Type Of Service Field in IP header

} UDP_ENDPOINT_PARMS;

typedef struct tag_UDP_V6_ENDPOINT_PARMS
{

    DWORD size;
    BYTE  trafficClass;  // Indicates the class or priority of the IPv6 packet
    DWORD flowLabel;     // Indicates the specific sequence the IPv6 packet belongs to

} UDP_V6_ENDPOINT_PARMS;


// Packet Media Endpoint initialization - address and parameters

typedef struct
{

    // Address attributes
    DWORD           nTimeslot;        // LOGICAL Timeslot address

} PKTMEDIA_ENDPOINT_ADDR;

typedef struct
{

    DWORD size;
    DWORD reserved;                   // must be 0

} PKTMEDIA_ENDPOINT_PARMS;


typedef struct
{
    // Address attributes
    DWORD           nTimeslot;        // LOGICAL Timeslot address

} MONITOR_ENDPOINT_ADDR;

typedef struct
{

    DWORD size;
    DWORD reserved;                   // must be 0

} MONITOR_ENDPOINT_PARMS;





// T.38 UDP Endpoint initialization - address and parameters

/************************************************************/
/* T.38 Fax IFP Decode config buffer data structures        */
/************************************************************/

typedef struct tag_msp_T38IFPDEC_CONFIG
{
    DWORD   queue_size;
            /* Reorder Queue Size - number of IFP packets */
#define         T38IFPDEC_QUEUE_SIZE_DEFAULT  20  /* # of IFP */
#define         T38IFPDEC_QUEUE_SIZE_MIN      10  /* # of IFP */
#define         T38IFPDEC_QUEUE_SIZE_MAX     100  /* # of IFP */

    DWORD   buffering_time;
            /* Buffering time - in ms. Should be a multiple of 10 ms! */
#define         T38IFPDEC_BUFFERING_TIME_DEFAULT  200  /* (ms) */
#define         T38IFPDEC_BUFFERING_TIME_MIN        0  /* (ms) */
#define         T38IFPDEC_BUFFERING_TIME_MAX     1500  /* (ms) */

    DWORD   page_data_keep_alive_time;
            /* Page data keep alive time in ms. Should be a multiple of 10 ms! */
            /* If set to 0, option is disabled */
#define         T38IFPDEC_PAGE_DATA_KEEP_ALIVE_TIME_DEFAULT    0  /* (ms) */
#define         T38IFPDEC_PAGE_DATA_KEEP_ALIVE_TIME_MIN        0  /* (ms) */
#define         T38IFPDEC_PAGE_DATA_KEEP_ALIVE_TIME_MAX     4000  /* (ms) */
} msp_T38IFPDEC_CONFIG;

/*******************************************************************/
/* T.38 Fax IFP Encode config buffer data structures               */
/*******************************************************************/
typedef struct tag_msp_T38IFPENC_CONFIG
{
    DWORD   v21_bytes_per_ifp_packet;
#define         T38IFPENC_V21_BYTES_PER_PACKET_DEFAULT          1
#define         T38IFPENC_V21_BYTES_PER_PACKET_MIN              1
#define         T38IFPENC_V21_BYTES_PER_PACKET_MAX            128

    DWORD   page_modem_ifp_duration;
    /* page data IFP duration, in ms. Should be a multiple of 10 ms! */
#define         T38IFPENC_PAGE_MODEM_IFP_DURATION_DEFAULT  30  /* (ms) */
#define         T38IFPENC_PAGE_MODEM_IFP_DURATION_MIN      10  /* (ms) */
#define         T38IFPENC_PAGE_MODEM_IFP_DURATION_MAX     100  /* (ms) */

    DWORD   t30_indicator_send_count;
#define         T38IFPENC_T30_INDICATOR_SEND_COUNT_DEFAULT      3
#define         T38IFPENC_T30_INDICATOR_SEND_COUNT_MIN          1
#define         T38IFPENC_T30_INDICATOR_SEND_COUNT_MAX      65000

    DWORD   t30_indicator_send_period;
    /* Time between T30 indicators IFPs. Should be a multiple of 10 ms! */
#define         T38IFPENC_T30_INDICATOR_SEND_PERIOD_DEFAULT  10  /* (ms) */
#define         T38IFPENC_T30_INDICATOR_SEND_PERIOD_MIN      10  /* (ms) */
#define         T38IFPENC_T30_INDICATOR_SEND_PERIOD_MAX    1000  /* (ms) */
} msp_T38IFPENC_CONFIG;

/*******************************************************************/
/* T.38 Fax UDPTL Encode config buffer data structures             */
/*******************************************************************/
/* T.38 Redundancy Error Protection Schecme Configuration structure. */
typedef struct tag_T38UDPTL_REDUNDANCY_CFG
{
    /* See t38defs.h */
    DWORD   redundant_ifp_packets;        /* Number of redundant IFP packets */
#define         T38UDPTLENC_REDUNDANT_IFPS_DEFAULT           3  /* # of IFP per UDPTL */
#define         T38UDPTLENC_REDUNDANT_IFPS_MIN               0  /* # of IFP per UDPTL */
#define         T38UDPTLENC_REDUNDANT_IFPS_MAX               4  /* # of IFP per UDPTL */

} T38UDPTL_REDUNDANCY_CFG;

/* T.38 Parity FEC Error Protection Schecme Configuration structure. */
typedef struct tag_T38UDPTL_PARITY_FEC_CFG
{
    /*** NOTE: NOT SUPPORTED! ***/
    DWORD   ifp_pkts_per_fec_message;    /* Number of IFP Packets per Parity FEC Message */
#define         T38UDPTLENC_PARITYFEC_IFPPKTS_PER_FECMSG_DEFAULT  0
#define         T38UDPTLENC_PARITYFEC_IFPPKTS_PER_FECMSG_MIN      0
#define         T38UDPTLENC_PARITYFEC_IFPPKTS_PER_FECMSG_MAX      0

    DWORD   fec_messages_per_udptl_pkt;  /* Number of Parity FEC Messages per T.38 UDPTL Packet */
#define         T38UDPTLENC_PARITYFEC_FECMSGS_PER_UDPTLPKT_DEFAULT  0
#define         T38UDPTLENC_PARITYFEC_FECMSGS_PER_UDPTLPKT_MIN      0
#define         T38UDPTLENC_PARITYFEC_FECMSGS_PER_UDPTLPKT_MAX      0
} T38UDPTL_PARITY_FEC_CFG;

typedef struct tag_msp_T38UDPTLENC_CONFIG
{
    DWORD   error_protection_scheme;
#define T38UDPTL_EPS_REDUNDANCY     0
#define T38UDPTL_EPS_PARITY_FEC     1
#define T38UDPTL_EPS_DEFAULT        T38UDPTL_EPS_REDUNDANCY

    union
    {
        T38UDPTL_REDUNDANCY_CFG  redundancy;
        T38UDPTL_PARITY_FEC_CFG  parity_fec; /*** NOTE: NOT SUPPORTED! ***/
    } eps;

    DWORD   num_duplicate_v21_udptl_packets; /* Number of Duplicate V.21 UDPTL packets to transmit. */
#define         T38UDPTLENC_PACKET_DUPLICATION_V21_DEFAULT       0
#define         T38UDPTLENC_PACKET_DUPLICATION_V21_MIN           0
#define         T38UDPTLENC_PACKET_DUPLICATION_V21_MAX           5

    DWORD   num_duplicate_indicator_udptl_packets; /* Number of Duplicate Indicator UDPTL packets to transmit. */
#define         T38UDPTLENC_PACKET_DUPLICATION_INDICATOR_DEFAULT 0
#define         T38UDPTLENC_PACKET_DUPLICATION_INDICATOR_MIN     0
#define         T38UDPTLENC_PACKET_DUPLICATION_INDICATOR_MAX     5

    DWORD   num_duplicate_page_modem_udptl_packets; /* Number of Duplicate Page Modem UDPTL packets to transmit. */
#define         T38UDPTLENC_PACKET_DUPLICATION_PAGE_MODEM_DEFAULT 0
#define         T38UDPTLENC_PACKET_DUPLICATION_PAGE_MODEM_MIN     0
#define         T38UDPTLENC_PACKET_DUPLICATION_PAGE_MODEM_MAX     5
} msp_T38UDPTLENC_CONFIG;

typedef struct tag_T38UDP_ENDPOINT_ADDR
{
    // UDP parameters
    char       DestIpAddress[20];  // destination IP address in dot notation
    WORD       nDestPort;          // destination port number
    char       SourceIpAddress[20];// source IP address in dot notation
    WORD       nSourcePort;        // source port number

} T38UDP_ENDPOINT_ADDR;


/*******************************************************************/
/* T.38 Fax UDPTL Decode config buffer data structures             */
/*******************************************************************/
typedef struct tag_msp_T38UDPTLDEC_CONFIG
{
    DWORD   enable_error_recovery; /* Decode and Recover missing IFPs
                                       - 0 = disable, 1 = enable */
            #define T38UDPTLDEC_ENABLE_ERROR_RECOVERY_DEFAULT  1
} msp_T38UDPTLDEC_CONFIG;


typedef struct  tag_T38UDP_ENDPOINT_PARMS
{
    DWORD size;
    // QoS
    BYTE TypeOfService;            // IPv4 TOS Type Of Service Field in IP header

    // T.38 UDPTL decoder parameters
    msp_T38UDPTLDEC_CONFIG  UdptlDecodeParms;

    // T.38 UDPTL encoder parameters
    msp_T38UDPTLENC_CONFIG UdptlEncodeParms;

    // T.38 IFP decoder parameters
    msp_T38IFPDEC_CONFIG IfpDecodeParms;

    // T.38 IFP encoder parameters
    msp_T38IFPENC_CONFIG IfpEncodeParms;

} T38UDP_ENDPOINT_PARMS;


// TPKT Endpoint Parameters

// Throughpacket vocoder types and channel types

typedef enum tpkt_coder_types
{
    kG726_16                    =0 ,
    kG723Low                    =1,
    kG723High                   =2,
    kG729                       =3,
    kG711Alaw_64                =4,
    kG711Mulaw                  =5,
    kNetCoder96                 =6,
    kG726_32                    =7,
    kG728                       =8,
    kNetCoder72                 =9,
    kG727_32                    =11,
    kNetCoder48                 =12,
    kTransparentCoder           =13,
    kNullCodec                  =100

} TPKT_CODER_TYPES;

typedef enum tpkt_delivery_method
{
    kNoNetDeliveryMethod        =0,
    kSimplePacket               =1,
    kComplexPacket              =2,
    kv2CompatiblePacket         =5,
    kRtpPacket                  =6,
    kCurrentNetDeliveryMethod   =7

} TPKT_DELIVERY_METHOD;


typedef struct tag_TPKT_ENDPOINT_PARMS
{
    DWORD   localSessionID;         // Local session ID used
    DWORD   localSessionSeq;        // 0|1 Sequence number for detecting session overlap
    DWORD   remoteSessionID;        // Remote Session ID used
    DWORD   remoteSessionSeq;       // 0|1 Sequence number for detecting session overlap
    DWORD   deliveryMethod;         // Session delivery method Simple/Complex
    BYTE    remoteGatewayIP[4];     // Destination Gateway for this session
    DWORD   coderType;              // Vocoder Type

} TPKT_ENDPOINT_PARMS;

// MUX Endpoint initialization - address and parameters

typedef struct tag_MUX_ENDPOINT_ADDR
{

    // Address attributes 
    DWORD           nTimeslot;        // Timeslot address 

} MUX_ENDPOINT_ADDR;

typedef struct tag_MUX_ENDPOINT_PARMS
{
    
    DWORD size;
    MSP_MUX_MEDIA media;
    
} MUX_ENDPOINT_PARMS;


// Generic Endpoint initialization parameters

typedef struct tag_OTHER_ENDPOINT_PARMS
{

    DWORD size;
    DWORD configCode;
    DWORD buf[MSP_ENDPOINT_PARAM_MAXSIZE];

} UNDEFINED_ENDPOINT_PARMS;



// MSPP CHANNEL FILTER INITIALIZATION PARAMETERS

typedef struct tag_msp_FILTER_ASSEMBLER_PARMS
{

    DWORD size;
    DWORD frame_quota;

} msp_FILTER_ASSEMBLER_PARMS;


typedef struct tag_msp_FILTER_DISASSEMBLER_PARMS
{

    DWORD size;
    DWORD vocoder;
    DWORD payload_id;

} msp_FILTER_DISASSEMBLER_PARMS;


typedef struct tag_msp_FILTER_JITTER_PARMS
{

    DWORD size;
    DWORD depth;
    DWORD adapt_enabled;
//    DWORD rfd;

} msp_FILTER_JITTER_PARMS;


typedef struct tag_msp_FILTER_ENCODER_PARMS
{

    DWORD size;
    WORD Mode;
    WORD Gain;
    WORD VadControl;
    WORD NotchControl;
    WORD IPFormat;
    WORD Rate;
    WORD PayloadID;
    WORD DtmfMode;

} msp_FILTER_ENCODER_PARMS;


typedef struct tag_msp_FILTER_DECODER_PARMS
{

    DWORD size;
    WORD Mode;
    WORD Gain;
    WORD IPFormat;
    WORD PayloadID;
    WORD DtmfMode;

} msp_FILTER_DECODER_PARMS;


typedef struct tag_MSP_VOICE_CHANNEL_PARMS
{
    // The structures below are defined above

    DWORD size;

    msp_FILTER_JITTER_PARMS JitterParms;

    msp_FILTER_ENCODER_PARMS EncoderParms;

    msp_FILTER_DECODER_PARMS DecoderParms;

} MSP_VOICE_CHANNEL_PARMS;

// Video channel - Video Jitter filter only!!!
typedef struct tag_MSP_VIDEO_CHANNEL_PARMS
{
    // The structures below are defined above
    
    DWORD size;

    msp_FILTER_JITTER_PARMS JitterParms;
	
} MSP_VIDEO_CHANNEL_PARMS;

// Audio channel - AMR encoder/decoder filters only!!!
typedef struct tag_MSP_AUDIO_CHANNEL_PARMS
{
    // The structures below are defined above
    
    DWORD size;

    msp_FILTER_ENCODER_PARMS EncoderParms;
    
    msp_FILTER_DECODER_PARMS DecoderParms;
    
} MSP_AUDIO_CHANNEL_PARMS;


typedef struct tag_msp_FILTER_FAXRELAY_CONFIG
{
    WORD    modemask;  /* Config mask */
              #define FAXRELAY_MODEMASK_DISABLE_NSF_FILTERING  0x0001
              #define FAXRELAY_MODEMASK_DISABLE_ECM            0x0002
              #define FAXRELAY_MODEMASK_ENABLE_NON_STD_T38_ECM 0x0004
              #define FAXRELAY_MODEMASK_RESERVED               0xFFF8
            #define FAXRELAY_MODEMASK_DEFAULT                  FAXRELAY_MODEMASK_DISABLE_ECM

    WORD    eventmask;/* Unsolicited event mask */
            #define FAXRELAY_EVENTMASK_DEFAULT                 0x0003
              #define FAXRELAY_EVENTMASK_REPT_FAX_BEGIN_END    0x0001
                      /* Report the beginning and ending of a fax session */
                      /* See: MSPEVN_FAXRELAY_FAX_BEGIN in mspunsol.h     */
              #define FAXRELAY_EVENTMASK_REPT_PASSED_PAGE      0x0002
                      /* Report successful passing of a fax page        */
                      /* See: MSPEVN_FAXRELAY_PASSED_PAGE in mspunsol.h */
              #define FAXRELAY_EVENTMASK_RESERVED              0xFFFC

    WORD    maxbitrate;/* Maximum bit rate of fax transmission */
            #define FAXRELAY_MAXBITRATE_DEFAULT                 14400
              #define FAXRELAY_MAXBITRATE_14400                 14400
              #define FAXRELAY_MAXBITRATE_9600                   9600
              #define FAXRELAY_MAXBITRATE_4800                   4800
              #define FAXRELAY_MAXBITRATE_2400                   2400
              #define FAXRELAY_MAXBITRATE_DISABLE_FILTER            0

    WORD    timeout;  /* Timeout value in milliseconds */
            #define FAXRELAY_TIMEOUT_DEFAULT                    15000
              #define FAXRELAY_TIMEOUT_MIN                          0
              #define FAXRELAY_TIMEOUT_MAX                      32000
} msp_FILTER_FAXRELAY_CONFIG;


typedef struct tag_MSP_FAX_CHANNEL_PARMS
{
    // Fax channel initialization parameters

    DWORD size;
    msp_FILTER_FAXRELAY_CONFIG FaxRelayParms;

} MSP_FAX_CHANNEL_PARMS;


typedef struct tag_MSP_RTP_SWITCHING_CHANNEL_PARMS
{

    DWORD size;
    DWORD parms [256];

} MSP_RTP_SWITCHING_CHANNEL_PARMS;


typedef struct tag_MSP_UNDEFINED_CHANNEL_PARMS
{

    DWORD size;
    DWORD parms [256];

} MSP_UNDEFINED_CHANNEL_PARMS;


#ifdef __cplusplus
}
#endif

#endif

